<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script>
      function loadXMLDoc() {
        setCookie('name1', '随便', 1)
        var xmlhttp = new XMLHttpRequest() //实例化 xml请求对象
        xmlhttp.onreadystatechange = function () {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById('myDiv').innerHTML = xmlhttp.responseText
          }
        }
        xmlhttp.setRequestHeader(
          'content-type',
          'application/x-www-form-urlencoded'
        )
        xmlhttp.open('POST', 'https://liu.zzgoodqc.cn/login')
        xmlhttp.send('username=web2112&password=jiayou2112')
      }
      function setCookie(cname, cvalue, exdays) {
        var d = new Date()
        d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000)
        var expires = 'expires=' + d.toUTCString()
        document.cookie = cname + '=' + cvalue + '; ' + expires
      }
      function getCookie(cname) {
        var name = cname + '=' //xiaowang=
        var ca = document.cookie.split(';')
        for (var i = 0; i < ca.length; i++) {
          var c = ca[i].trim() //去除字符串两边空格
          if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length)
          }
        }
        return ''
      }
    </script>
  </head>
  <body>
    <div id="myDiv"><h2>使用 AJAX 修改该文本内容</h2></div>
    <button type="button" onf onclick="loadXMLDoc()">修改内容</button>
    <a href="day6-reg.html">aaa</a>
  </body>
</html>
